<template>
	<view class="">
		<u-sticky>
			<view class="search-box pb-10">
				<u-search placeholder="请输入" shape="square" v-model="searchData.name" @search="onSearch" :showAction="false" />
				<view class="custom-btn" @click="affirm">确认派发</view>
			</view>
		</u-sticky>
		<view class="my-list bg-white mt-10">
			<u-checkbox-group v-model="subData.ids" shape="circle" activeColor="#e54d42" placement="column" iconPlacement="right">
				<view class="pt-30 pb-30 pr-20 border-b" v-for="(item, index) in dataList" :key="item.id">
					<u-checkbox :name="item.staffId" :label="item.userName"/>
				</view>
			
				<!-- <u-list :height="swiperHeight" v-if="dataList.length > 0">
					<u-list-item v-for="(item, index) in dataList" :key="item.id">
						<view class="item mt-0 border-b pt-30 pb-30 flex align-center">
							<u-checkbox :name="item.staffId" :label="item.userName"/>
						</view>
					</u-list-item>
				</u-list> -->
			</u-checkbox-group>
		</view>
		<!-- 无数据时默认显示 -->
		<view class="emptybox" v-if="dataList.length == 0">
			<u-empty icon-size="150" text="暂无数据" mode="data"></u-empty>
		</view>
		<u-popup :show="showInput" :round="10" mode="center" @close="showInput= false" :safeAreaInsetBottom="false">
			<view class="pl-30 pr-30 pt-46 pb-46 flex flex--row align-center">
				<u-input v-model="subData.nums" inputAlign="center" placeholder="输入派发数量" type="number"/>
				<view class="mt-30 width-146">
					<u-button text="确认" color="#e54d42" @click="onSubmit"/>
				</view>
			</view>
		</u-popup>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	// import listHeightMixin from '@/common/computedAltitude.js'
	export default {
		// mixins:[listHeightMixin],
		data() {
			return {
				dataList: [],
				showInput:false,
				checkboxValue:[],
				searchData: {
					name:'',
					page: 1,
					limit: 999
				},
				subData:{
					ids:[],
					cardItemId: null,
					nums: null,
				},
				loadmore:{
					status: 'loadmore',
					iconType: 'flower',
					loadText: {
						loadmore: '轻轻上拉',
						loading: '努力加载中',
						nomore: '实在没有了'
					}
				}
			}
		},
		onLoad(opt) {
			this.subData.cardItemId = opt.cardItemId
			this.getPageList()
		},
		methods: {
			onSubmit(){
				const that = this
				if(uni.$u.test.isEmpty(that.subData.nums)){
					that.$refs.uToast.show({
						message:'请输入派发数量'
					})
				}else {
					this.$reqJsonPost('StockHolderGiftBagDoCreate', this.subData).then(res=>{
						this.$refs.uToast.show({
						message:res.msg,
						complete(){
							uni.navigateBack()
						}
					})
					})
				}
			},
			affirm(){
				if(this.subData.ids.length === 0){
					this.$refs.uToast.show({
						message:'请选择联创'
					})
				}else {
					this.showInput = true
				}
			},
			getPageList(){
				this.$reqPost('GetStockHolderList', this.searchData).then(res=>{
					this.dataList = res.data
				})
			},
			onSearch(value) {
				this.searchData.page = 1
				this.dataList = []
				this.getPageList()
			},
		}

	}
</script>

<style lang="scss" scoped>
	
</style>